import {setItem,getItem} from "@/utils/localStorage"
import {nanoid} from "nanoid"

const userTempIdType = "userTempId"
function userTempId (){
//先判断当前是否存在用户临时id
 if(getItem(userTempIdType)){
    return getItem(userTempIdType)
   }
   
//如果不存在用户临时id,则创建一个用户临时id 并保存起来 然后返回出去
  const userTempId= nanoid()
  setItem(userTempIdType,userTempId)
  return userTempId
}

export default userTempId